<?php

namespace App\Http\Controllers\api;

use App\Http\Controllers\Controller;
use App\Http\Repository\MapHouseRepository;
use App\Models\House;
use App\Models\RentHouse;
use Illuminate\Http\Request;

class MapHouseController extends Controller
{
    /**
     * @param Request $request
     * @return false|string
     * Su ang
     * 房源地图展示
     */
    public function index(Request $request)
    {
        $id = $request->get('tab');
        if (!empty($id) && !is_numeric($id)){
            return 'id错误';
        }
        return MapHouseRepository::index($id);


    }

    public static function indexs()
    {

            $data = House::with(['direction','propertyType','houseRoom','houseYear','city'])->where('house_type','<>','2')->get()->groupBy('longitude','latitude')->toarray();
           return json_encode(['code'=>200,'data'=>$data]);
    }
    public function  rentHouse(Request $request)
    {
        $data = $request->all();
        RentHouse::create($data);
        return json_encode(['data'=>$data]);
    }
}
